package com.gipson.amc.utils.sort;

import com.gipson.amc.entity.Authority;

import java.util.Comparator;

/**
 * 根据authority.code升序排序。
 *
 * @author cjw 2020-05-08
 */
public class AuthorityComparator implements Comparator<Authority> {
	
	/**
	 * 根据authority.code升序排序。
	 *
	 * @param
	 * @return
	 * @author cjw 2020-05-08
	 */
	@Override
	public int compare(Authority authority_1, Authority authority_2) {
		//根据authority.code升序排序。
		return compareByCodeAsc(authority_1, authority_2);
	}
	
	/**
	 * 根据authority.code升序排序。
	 *
	 * @param
	 * @return
	 * @author cjw 2020-05-08
	 */
	public int compareByCodeAsc(Authority authority_1, Authority authority_2) {
		String code_1 = authority_1.getCode();
		String code_2 = authority_2.getCode();
		int diff = code_1.compareTo(code_2);
		return diff;
	}
	
	
}
